import dayjs from "dayjs";

export const certiOptions = [
  {
    value: "jyz",
    label: "结业证书",
  },
  {
    value: "shsjz",
    label: "活动证书",
  },
  {
    value: "jshyz",
    label: "注册教师证书",
  },
  {
    value: "hzdwz",
    label: "合作单位证书",
  },
];

export const categoryOptions = [
  {
    value: "first",
    label: "首次审核",
  },
  {
    value: "expiry",
    label: "到期审核",
  },
];

export const categoryMap = {
  first: "首次审核",
  expiry: "到期审核",
};

export const certiOptions2 = [
  {
    value: "jyz",
    label: "结业证书",
  },

  {
    value: "shsjz",
    label: "活动证书",
  },
];

export const certiMap = {
  jyz: "结业证书",
  jshyz: "注册教师证书",
  hzdwz: "合作单位证书",
  shsjz: "活动证书",
};

export const statusOptions = [
  {
    value: 0,
    label: "待审核",
  },
  // {
  //   value: 1,
  //   label: '审核中',
  // },
  {
    value: 2,
    label: "不通过",
  },
  {
    value: 3,
    label: "待缴费",
  },
  {
    value: 4,
    label: "已办结",
  },
];

export const statusMap = {
  0: "待审核",
  1: "审核中",
  2: "不通过",
  3: "待缴费",
  4: "已办结",
};

export const certiStatusOptions = [
  {
    value: 0,
    label: "已下线",
  },
  {
    value: 1,
    label: "生效中",
  },
  {
    value: 2,
    label: "已过期",
  },
];

export const certiStatusMap = {
  0: "已下线",
  1: "生效中",
  2: "已过期",
};

export const baseInfoPersonForm = [
  {
    label: "申请类别",
    key: "category",
    type: "select",
    options: categoryOptions,
    optional: true,
  },
  {
    label: "证书编号",
    key: "serialNumber",
    type: "serialNumber",
  },
  {
    label: "姓名",
    key: "name",
    type: "string",
    required: true,
    example: "张三",
  },
  {
    label: "拼音",
    key: "pinyin",
    type: "string",
    optional: true,
  },
  {
    label: "性别",
    key: "gender",
    type: "select",
    optional: true,
    options: [
      {
        label: "男",
        value: "男",
      },
      {
        label: "女",
        value: "女",
      },
    ],
  },
  {
    label: "出生年月",
    key: "birthDate",
    type: "date",
    optional: true,
    default: "2000-01-01",
  },
  {
    label: "民族",
    key: "nation",
    type: "string",
    optional: true,
  },
  {
    label: "居住所在地",
    key: "address",
    type: "string",
    optional: true,
  },
  {
    label: "籍贯",
    key: "nativePlace",
    type: "string",
    optional: true,
  },
  {
    label: "政治面貌",
    key: "politicalAffiliation",
    type: "string",
    optional: true,
  },
  {
    label: "联系电话",
    key: "mobile",
    type: "string",
    optional: true,
  },
  {
    label: "邮箱",
    key: "email",
    type: "email",
    optional: true,
  },
  // {
  //   label: '证件类型',
  //   key: 'cardType',
  //   type: 'string',
  //   optional: true,
  //   example: '2',
  // },
  {
    label: "身份证号码",
    key: "cardNo",
    type: "string",
    optional: true,
  },
  {
    label: "邮寄地址",
    key: "mailAddress",
    type: "string",
    optional: true,
  },
  {
    label: "教育背景",
    key: "eduBg",
    type: "string",
    optional: true,
  },
  {
    label: "工作经历",
    key: "workExperience",
    type: "textarea",
    optional: true,
  },
  {
    label: "所获荣誉",
    key: "honors",
    type: "textarea",
    optional: true,
  },
  {
    label: "推荐机构(推荐人)",
    key: "recommend",
    type: "string",
    optional: true,
  },
  {
    label: "所在地区",
    key: "region",
    type: "area",
    optional: true,
  },
  {
    label: "个人照片",
    key: "picFile",
    type: "file",
    optional: true,
  },
];

export const baseInfoPersonForm2 = [
  {
    label: "申请类别",
    key: "category",
    type: "select",
    options: categoryOptions,
    optional: true,
  },
  {
    label: "证书编号",
    key: "serialNumber",
    type: "serialNumber",
  },
  {
    key: "name",
    type: "string",
    label: "单位名称",
    required: true,
    example: "李四",
  },
  {
    key: "address",
    type: "string",
    label: "单位地址",
    required: false,
  },
  {
    key: "subjection",
    type: "select",
    label: "隶属管辖",
    required: false,
    options: [
      {
        label: "工商",
        value: "工商",
      },
      {
        label: "教委",
        value: "教委",
      },
    ],
  },
  {
    key: "establishmentDate",
    type: "date",
    label: "机构成立时间",
    required: false,
    default: "2000-01-01",
  },
  {
    key: "contactUser",
    type: "string",
    label: "单位负责人",
    required: false,
  },
  {
    key: "contactPhone",
    type: "string",
    label: "联系电话",
    required: false,
  },
  {
    key: "contactPosition",
    type: "string",
    label: "担任职务",
    required: false,
  },
  {
    key: "campusCount",
    type: "number",
    format: "int32",
    label: "校区数量",
    required: false,
  },
  {
    key: "totalCampusArea",
    type: "number",
    format: "double",
    label: "校区总面积(平方米)",
    required: false,
  },
  {
    key: "studentAgeRange",
    type: "rangenumber",
    label: "学员年龄区间",
    required: false,
  },

  {
    key: "studentsCount",
    type: "number",
    format: "int32",
    label: "舞蹈生在籍人数",
    required: false,
    example: 1499,
  },
  {
    key: "ftTeachersCount",
    type: "number",
    format: "int32",
    label: "全职教师人数",
    required: false,
    example: 32332,
  },
  {
    key: "gradingSystem",
    type: "string",
    label: "考级体系",
    required: false,
  },

  {
    key: "recommend",
    type: "string",
    label: "推荐单位(推荐人)",
    required: false,
  },
  {
    key: "region",
    type: "area",
    label: "所在地区",
    required: false,
  },
  {
    key: "mainCourses",
    type: "textarea",
    label: "主营课程",
    required: false,
  },
  {
    key: "description",
    type: "textarea",
    label: "单位介绍",
    required: false,
    example: "你说的对",
  },
];

export const baseInfoPersonForm3 = [
  {
    label: "证书类型",
    key: "certType",
    type: "select",
    options: certiOptions,
    optional: true,
  },
  {
    label: "姓名",
    key: "holderName",
    type: "string",
    depend: {
      certType: ["jshyz"],
    },
  },
  {
    label: "身份证",
    key: "cardNo",
    type: "string",
    depend: {
      certType: ["jshyz"],
    },
  },
  {
    label: "单位名称",
    key: "holderName",
    type: "string",
    depend: {
      certType: ["hzdwz"],
    },
  },
  {
    label: "地区",
    key: "region",
    type: "area",
    depend: {
      certType: ["hzdwz"],
    },
  },
  {
    label: "持有人/单位",
    key: "holderName",
    type: "string",
    depend: {
      certType: ["jyz", "shsjz"],
    },
  },
  {
    label: "证书编号",
    key: "serialNumber",
    type: "string",
    depend: {
      certType: ["jyz", "shsjz"],
    },
  },
];

export const applyDataAdapter = (data) => {
  if (data.region) {
    data.region = data.region?.join(",");
  }

  return data;
};

export const initDataAdapter = (data) => {
  console.log("😈data.birthDate", data.birthDate);
  return {
    ...data,
    birthDate: data.birthDate ? dayjs(data.birthDate) : null,
    establishmentDate: data.establishmentDate
      ? dayjs(data.establishmentDate)
      : null,
  };
};
